Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: isReturn and total methods #106

Merged
merged 14 commits into from
Nov 6, 2024

Conversation

shahin-hq
Copy link
Contributor

@shahin-hq shahin-hq commented Nov 4, 2024

}
}

return isReturn;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ensures that isReturn will return true only when all of the recipients are the same as sender.


return isReturn;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above but for the signed transactions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahin-hq I think here we could use the this.isReturn() from the signed dto in the coins, or do you see any issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that before but couldn't because I couldn't find a way to access given wallet in coin class.

return [this.#wallet.address(), this.#wallet.publicKey()].includes(this.sender());

@@ -131,11 +148,25 @@ export class ExtendedSignedTransactionData {
}

public total(): number {
if (this.isReturn()) {
return this.amount() - this.fee();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a transaction is a returning the fee should be subtracted

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added total calculation for multipayment signed transactions. The same as confirmed transaction:

if (this.isMultiPayment()) {

@shahin-hq shahin-hq marked this pull request as ready for review November 5, 2024 09:56
@ItsANameToo ItsANameToo merged commit c051445 into develop Nov 6, 2024
2 checks passed
@ItsANameToo ItsANameToo deleted the refactor/confirmed-signed-tx-data branch November 6, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants